var putChart;
var realTimeChart;
$(function(){

    putChart = function (last_year,this_year) {
        var Chart1 = echarts.init(document.getElementById('zchart'), 'walden');
        var option = {
            title : {
                /*text: '每月销售额',
                subtext: '单位:万元'*/
            },
            tooltip : {
                trigger: 'axis'
            },
            legend: {
                display:false
            },
            toolbox: {
                show : false, //操作项
                feature : {
                    mark : {show: true},
                    dataView : {show: false, readOnly: false},
                    magicType : {show: true, type: ['line', 'bar']},
                    restore : {show: false},
                    saveAsImage : {show: false}
                }
            },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    data : ["01月", "02月", "03月", "04月", "05月", "06月", "07月", "08月", "09月", "10月", "11月","12月"],

                },
            ],
            yAxis : [
                {
                    type : 'value'
                }
            ],
            series : [
                {
                    name:'去年销售额',
                    type:'bar',
                    itemStyle : { normal: {label : {show: true, position: 'inside'}, color:'#6494f6'}},
                    data:[12,22,33,15,17,23,25,19,32,25,28,11],
                    markPoint : {
                        data : [
                            {type : 'max', name: '最大值'},
                            {type : 'min', name: '最小值'}
                        ]
                    },
                    markLine : {
                        data : [
                            {type : 'average', name: '平均值'}
                        ]
                    }
                },
                {
                    name:'今年销售额',
                    type:'bar',
                    itemStyle : { normal: {label : {show: true, position: 'inside'}, color:'#62d9ac'}},
                    data:[12,22,23,15,17,33,25,29,32,25,28,11],
                    markPoint : {
                        data : [
                            {type : 'max', name: '最大值'},
                            {type : 'min', name: '最小值'}
                        ]
                    },
                    markLine : {
                        data : [
                            {type : 'average', name: '平均值'}
                        ]
                    }
                },

            ]
        };
        Chart1.setOption(option);
    };
    putChart();

    realTimeChart = function(){
        var option;
        var Chart2 = echarts.init(document.getElementById('rchart'),'walden');
        option = {
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00']
            },
            yAxis: {
                type: 'value'
            },
            series: [{
                data: [820, 932, 901, 934, 1290, 1130, 1520, 1720, 1220, 799, 838, 965, 872, 888, 799, 825, 1005, 1132, 1241, 1520, 1720, 901, 934, 934],
                type: 'line',
                areaStyle: {}
            }]
        };
        Chart2.setOption(option);
    };
    realTimeChart();

    llChart = function () {
        var option;
        var Chart3 = echarts.init(document.getElementById('lchart'),'walden');
        option = {
            title: {
                text: '商城用户注册来源',
                subtext: '流量分析',
                left: 'center'
            },
            tooltip: {
                trigger: 'item'
            },
            legend: {
                orient: 'vertical',
                left: 'left',
            },
            series: [
                {
                    name: '访问来源',
                    type: 'pie',
                    radius: '50%',
                    data: [
                        {value: 1048, name: '搜索引擎'},
                        {value: 735, name: '直接访问'},
                        {value: 580, name: '邮件营销'},
                        {value: 484, name: '联盟广告'},
                        {value: 300, name: '视频广告'}
                    ],
                    emphasis: {
                        itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        Chart3.setOption(option);
    };
    llChart();
});
